package main

import "fmt"

// 返回一个“返回int的函数”
func fibonacci() func() int {
	a := 0
	b := 1
	init := 0
	c := 0
	return func()int{
		if(init == 0){
			c = 0
			init += 1
		}else if(init == 1){
			c = 1
			init += 1
		}else{
			c = a + b
			a = b
			b = c
		}
		return c
	}
}

func main() {
	f := fibonacci()
	for i := 0; i < 10; i++ {
		fmt.Println(f())
	}
}
